package cn.com.xinjinfu.pdoulcProduct.engine;

/**
 * Created by android-adt on 2016/1/11.
 */
import android.graphics.drawable.GradientDrawable;
import android.os.CountDownTimer;
import android.widget.Button;

public class ButtonsCd extends CountDownTimer {
    private Button bn;
    GradientDrawable myGrad;
    /**
     * @param millisInFuture
     *  读秒时间
     * @param countDownInterval
     * 每countDownInterval的时间执行onclick,更新
     */
    public ButtonsCd(long millisInFuture, long countDownInterval,Button btn) {
        super(millisInFuture, countDownInterval);
        bn = btn;
        myGrad = (GradientDrawable)bn.getBackground();
        myGrad.setColor(0xFF6ED3D6);
    }

    @Override
    public void onTick(long millisUntilFinished) {
        bn.setText((millisUntilFinished-10)/1000+"后重新获取");
        myGrad.setColor(0xFFCCCCCC);
    }
    @Override
    public void onFinish() {
        bn.setText("重新获取");
        bn.setEnabled(true);
        myGrad.setColor(0xFF6ED3D6);
    }
}

